package com.lzs.adx.web.modules.job.task;

import com.lzs.adx.web.commmon.utils.DateUtil;
import com.lzs.adx.web.modules.adx.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
@Slf4j
public class DeleteDataTask implements ITask{

    @Autowired
    private ReportService reportService;
    @Override
    public void run(String params) {
        log.info("执行数据清除任务开始");
        String dayDate;
        if(StringUtils.isNotBlank(params)){
            dayDate=params;
        }else{
            LocalDateTime yesterdayStartingTime = DateUtil.getYesterdayStartingTime();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            dayDate= formatter.format(yesterdayStartingTime);
        }
        reportService.deleteInfo(dayDate);
        log.info("执行数据清除任务结束");
    }
}
